package com.lqwu.openAPI.model.enums;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 接口状态枚举
 */
public enum InterfaceStatusEnum {
    OFFLINE("下线", 0),
    ONLINE("上线", 1);

    private final String text;
    private final Integer value;

    InterfaceStatusEnum(String text, Integer value) {
        this.text = text;
        this.value = value;
    }

    public static List<String> getValues() {
        return Arrays.stream(InterfaceStatusEnum.values())
                .map(InterfaceStatusEnum::getValue)
                .map(String::valueOf)
                .collect(Collectors.toList());
    }

    public static InterfaceStatusEnum getEnumByValue(Integer value) {
        for (InterfaceStatusEnum anInterfaceStatusEnum : InterfaceStatusEnum.values()) {
            if (anInterfaceStatusEnum.value.equals(value)) {
                return anInterfaceStatusEnum;
            }
        }
        return null;
    }

    public String getText() {
        return text;
    }

    public Integer getValue() {
        return value;
    }
}
